package com.ruoyi.cust.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cust.domain.BCusInfo;
import com.ruoyi.cust.service.IBCusInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户信息Controller
 *
 * @author ljs
 * @date 2025-10-02
 */
@RestController
@RequestMapping("/cust/BCusInfo")
public class BCusInfoController extends BaseController
{
    @Autowired
    private IBCusInfoService bCusInfoService;

    /**
     * 查询客户信息列表
     */
    //@PreAuthorize("@ss.hasPermi('cust:BCusInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BCusInfo bCusInfo)
    {
        startPage();
        List<BCusInfo> list = bCusInfoService.selectBCusInfoList(bCusInfo);
        return getDataTable(list);
    }


    /**
     * 导出客户信息列表
     */
    @PreAuthorize("@ss.hasPermi('cust:BCusInfo:export')")
    @Log(title = "客户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BCusInfo bCusInfo)
    {
        List<BCusInfo> list = bCusInfoService.selectBCusInfoList(bCusInfo);
        ExcelUtil<BCusInfo> util = new ExcelUtil<BCusInfo>(BCusInfo.class);
        util.exportExcel(response, list, "客户信息数据");
    }

    /**
     * 获取客户信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('cust:BCusInfo:query')")
    @GetMapping(value = "/{bCusId}")
    public AjaxResult getInfo(@PathVariable("bCusId") Long bCusId)
    {
        return success(bCusInfoService.selectBCusInfoByBCusId(bCusId));
    }

    /**
     * 新增客户信息
     */
    @PreAuthorize("@ss.hasPermi('cust:BCusInfo:add')")
    @Log(title = "客户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BCusInfo bCusInfo)
    {
        return toAjax(bCusInfoService.insertBCusInfo(bCusInfo));
    }

    /**
     * 修改客户信息
     */
    @PreAuthorize("@ss.hasPermi('cust:BCusInfo:edit')")
    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BCusInfo bCusInfo)
    {
        return toAjax(bCusInfoService.updateBCusInfo(bCusInfo));
    }

    /**
     * 删除客户信息
     */
    @PreAuthorize("@ss.hasPermi('cust:BCusInfo:remove')")
    @Log(title = "客户信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{bCusIds}")
    public AjaxResult remove(@PathVariable Long[] bCusIds)
    {
        return toAjax(bCusInfoService.deleteBCusInfoByBCusIds(bCusIds));
    }
}
